import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsNotEmpty, IsString } from 'class-validator';
import { IdObject } from 'src/common/utils/types';

export class BasePairDto {
  @ApiProperty({ description: '组合名称', type: String })
  @IsNotEmpty()
  @IsString()
  name: string;
  @ApiProperty({ description: '参赛项目Id列表', type: IdObject, isArray: true })
  @IsNotEmpty()
  @Type(() => IdObject)
  events: IdObject[];
}

export class CreatePairDto extends BasePairDto {
  @ApiProperty({ description: '选手1Id', type: String })
  @IsNotEmpty()
  @IsString()
  player1Key: string;
  @ApiProperty({ description: '选手2Id', type: String })
  @IsNotEmpty()
  @IsString()
  player2Key: string;
}

export class UpdatePairDto {
  @ApiProperty({ description: '修改前的数据', type: BasePairDto })
  @IsNotEmpty()
  @Type(() => BasePairDto)
  from: BasePairDto;
  @ApiProperty({ description: '修改后的数据', type: CreatePairDto })
  @IsNotEmpty()
  @Type(() => CreatePairDto)
  to: CreatePairDto;
}
